package com.scau.meetingbook.mapper;

import com.scau.meetingbook.dto.MeetingRoomsDTO;
import com.scau.meetingbook.pojo.MeetingRooms;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

/**
 * <p>
 * 会议室表 Mapper 接口
 * </p>
 *
 * @author scau
 * @since 2025-06-07
 */
public interface MeetingRoomsMapper extends BaseMapper<MeetingRooms> {
    @Select("SELECT * FROM meeting_rooms")
    @Results({
            @Result(property = "roomId", column = "room_id"),
            @Result(property = "name", column = "name"),
            @Result(property = "type", column = "type"),
            @Result(property = "maxCapacity", column = "max_capacity"),
            @Result(property = "hourlyRentalPrice", column = "hourly_rental_price"),
            @Result(property = "status", column = "status"),
            @Result(property = "roomEquipments", column = "room_id",
                    many = @Many(select = "com.scau.meetingbook.mapper.RoomEquipmentMapper.findByRoomId",
                            fetchType = FetchType.EAGER))
    })
    List<MeetingRoomsDTO> selectAllMeetingRooms();

}
